package com.chris.seata_stock.service;

import com.chris.seata_stock.dao.StockDAO;
import com.chris.seata_stock.entity.StockPO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author wujf
 * @date 2022/1/19
 */
@Service
public class StockService {

    @Autowired
    private StockDAO stockDAO;

    @Transactional(rollbackFor = Exception.class)
    public boolean updateStock(StockPO po) {
        int i = stockDAO.updateByPrimaryKeySelective(po);
        return i>0;
    }

    public StockPO getStock(StockPO stockPO) {
        StockPO stockPO1 = stockDAO.selectOne(stockPO);
        return stockPO1;
    }

}
